#ifndef FTP_MANAGER_H
#define FTP_MANAGER_H

#include <QObject>
#include <QtNetwork/QFtp>
#include <QTimer>
#include <QStringList>
#include <QDebug>
#include <QFile>
#define DIR     1
#define FILE    2
class Ftp_manager : public QFtp
{
    Q_OBJECT
public:
    explicit Ftp_manager();

    Q_INVOKABLE void setHost(QString host,int port);
    Q_INVOKABLE void setLogin(QString user, QString password);
    Q_INVOKABLE void listage();
    Q_INVOKABLE void deconnecter();
    Q_INVOKABLE void Cd(QString cd_cmd);
    Q_INVOKABLE void createFolder(QString folderName);
    Q_INVOKABLE void remove(QString fileName);
    Q_INVOKABLE void downloadFile(QString fileName);
    Q_INVOKABLE void uploadFile(QString fileName);
signals:
    void connected();
    void erreurLogin();
    void erreurHost();
    void listingFinished();
    void downloadSuccesfull();
    void downloadError(QString msg);
    void downloadProgress(qint64 total,qint64 progress);
    void removeSuccesfull();
    void mkdirSuccesfull();
    void uploadSuccesfull();
    void uploadError(QString msg);
private:
    QStringList list_fileName;
    QStringList list_fileSize;
    QStringList list_fileType;
    QStringList list_last;
    QStringList list_create;
    QStringList list_owner;     //Proprietaire

    qint64 q_fini;
    qint64 q_total;

    QFile *file;
    void clearAllList();
    int listID;
    int cdID;
    int removeID;
    int createID;
    int getID;
    int putID;

public slots:
    void partageVar();
private slots:
    void checkConnection(int state);
    void listing(QUrlInfo urlInfo);
    void getError(int id, bool error);
    void transferProgress(qint64 fini, qint64 total);
    void cmdStart(int id);
};

#endif // FTP_MANAGER_H
